﻿#ifndef FRAMEMAIN_H
#define FRAMEMAIN_H

#include <QWidget>
#include <QPushButton>
#include <QToolButton>
#include <QMenuBar>
#include <QStatusBar>
#include <QLabel>
#include <QFrame>
#include <QTextEdit>
#include <QSize>
#include <QStyle>
#include <QMouseEvent>
#include <QPoint>
#include <QImage>
#include <QByteArray>
#include <QPaintEvent>

#define PADDING 2

#ifndef qout
#include <QDebug>
#define qout qDebug()
#endif

enum Direction { UP=0, DOWN=1, LEFT, RIGHT, LEFTTOP, LEFTBOTTOM, RIGHTBOTTOM, RIGHTTOP, NONE };


class FrameMain : public QWidget
{
    Q_OBJECT
public:
    explicit FrameMain(QWidget *parent = nullptr);
    ~FrameMain();

    void setMainWidget(QWidget *mainwidget);
    
    void setConfigWidget(QWidget *conf);

    QPixmap StdIcon(int num);

    void setFrameTitle(const QString &Title);

    QLabel *getLIcoObj();

    QLabel *getLTitleObj();

    void setLIcoSize(const QSize& FixedSize);

    void setTitleBarSize(const QSize& FixedSize);

    void HideStatBar(bool flag);

    void setStatusMsg(const QString & msg);

    void isSetAppModal(bool falg);

    void addWidgetInStatBar(QWidget *widget, int stretch = 0);

    QPixmap setSvgColor(QImage image, QColor color);

    void setFrameIco(const QString &picture = "");
public slots:

    void MinFrameMain();
    
    void MaxFrameMain();
protected:
    bool eventFilter(QObject * obj, QEvent * event);
    
//    void paintEvent(QPaintEvent *e);
private:
    

    void MainStructor();

    void getDialog();

private:
    QLabel *LIco,*LTitle;

    QMenuBar *menuBar;

    QToolButton *BtnSetting;
    QPushButton *BtnMin;
    QPushButton *BtnMax;
    QPushButton *BtnClose;

    QFrame *TitleBar;

    QWidget *MainWidget;

    QWidget *ConfigWidget;

    QStatusBar *StatBar;

    QTextEdit *Editor;

    bool m_leftButtonPressed;

    bool isWindowMax;

    QPoint startPos;
    QPoint winTopLeftPoint;
};

#endif // FRAMEMAIN_H
